module.exports = class extends think.Model {
  // eslint-disable-next-line camelcase
  async saveBySurveyId({ survey_id, ...form }) {
    const count = await this.where({ survey_id }).count();
    if (count > 0) {
      // eslint-disable-next-line no-return-await
      return await this.where({ survey_id }).update({ ...form, survey_id });
    } else {
      // eslint-disable-next-line no-return-await
      return await this.add({ ...form, survey_id });
    }
  }
};
